package com.qianxiwitmanagement.controller;

import com.qianxi.wit.pojo.TbAdministrator;
import com.qianxi.wit.pojo.TbSufferer;
import com.qianxi.wit.result.R;

import com.qianxiwitmanagement.service.TbSuffererService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class TbSuffererController {
    @Autowired
    private TbSuffererService tbSuffererService;

    @PostMapping("/findByToken")
    public R findByToken(@RequestBody TbSufferer tbSufferer){
        try {
            TbAdministrator tbSufferer1 =tbSuffererService.findByToken(tbSufferer);
            return R.ok().data("suffer",tbSufferer1);
        }catch (Exception e){
            e.printStackTrace();
            return  R.error();
        }

    }

    @PostMapping("/deleteByToken")
    public R deleteByToken(@RequestBody TbSufferer tbSufferer){
        try {
            tbSuffererService.deleteByToken(tbSufferer);
            return R.ok();
        }catch (Exception e){
            e.printStackTrace();
            return R.error();
        }
    }



}
